import request from './request'
import { useUserStore } from '../store/modules/user'
// 获取角色列表
export function getRoleList(data: object) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/role/getList',
    method: 'post',
    data,
    headers: token,
  })
}

// 批量启用或禁用角色状态
export function changeRole(data: any, params: { status: boolean }) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/role/disable',
    method: 'put',
    data,
    params,
    headers: token,
  })
}

// 批量删除角色
export function deleRole(data: any) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/role/',
    method: 'delete',
    data,
    headers: token,
  })
}

// 新增或修改角色权限
export function saveRole(data: any) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/role/save',
    method: 'post',
    data,
    headers: token,
  })
}
// 获取所有菜单权限
export function getAllAuthor() {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/customer/author/getAllAuthor',
    method: 'get',
    headers: token,
  })
}
// 根据角色ID获取角色权限
export function getRoleAuthor(id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/role/getRoleAuthor/' + id,
    method: 'get',
    headers: token,
  })
}
// 保存角色权限
export function saveRoleAuthor(data: any, id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/role/saveRoleAuthor/' + id,
    method: 'post',
    data,
    headers: token,
  })
}
// 根据账号获取菜单权限
export function getAuthors() {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/role/getAuthors',
    method: 'get',
    headers: token,
  })
}
